#include <cstdlib>
#include <math.h>
#include <sstream>
#include <stdio.h>
#include <Windows.h>
#include <conio.h>

#include "Board.h"
#include "Rook.h"
#include "Queen.h"
#include "Knight.h"
#include "Pawn.h"
#include "Bishop.h"
#include "King.h"

/*
====================
Constructor
DevX Team
====================
*/
dxBoard::dxBoard()
{
	position_t cpos;
	this->currentPlayer=WHITE;
    if (this->currentPlayer==WHITE) {
	cpos.row=7;
	cpos.column=7;
	} else {
	cpos.row=0;
	cpos.column=0;
	}
	this->currentPosition=cpos;
	this->selectedPosition=cpos;
	this->isSelected=false;
	this->isFinished=false;
	for(int i=0;i<ROWS;i++)
	{
		for(int j=0;j<COLUMNS;j++)
			this->pieces[i][j]=NULL;
	}
	// TODO: HERE SETUP PIECES (TOP BLACK, BOTTOM WHITE)  
	
	this->pieces[0][0]=new dxRook(BLACK,0,0);//Rook
	this->pieces[0][1]=new dxKnight(BLACK,0,1);//Knight
	this->pieces[0][2]=new dxBishop(BLACK,0,2);//Bishop
	this->pieces[0][3]=new dxQueen(BLACK,0,3);//Queen
	this->pieces[0][4]=new dxKing(BLACK,0,4);//King
	this->pieces[0][5]=new dxBishop(BLACK,0,5);//Bishop
  this->pieces[0][6]=new dxKnight(BLACK,0,6);//Knight
	this->pieces[0][7]=new dxRook(BLACK,0,7);//Rook
	//pawns
	this->pieces[1][7]=new dxPawn(BLACK,1,7);
	this->pieces[1][6]=new dxPawn(BLACK,1,6);
	this->pieces[1][5]=new dxPawn(BLACK,1,5);
    this->pieces[1][4]=new dxPawn(BLACK,1,4);
	this->pieces[1][3]=new dxPawn(BLACK,1,3);
	this->pieces[1][2]=new dxPawn(BLACK,1,2);
	this->pieces[1][1]=new dxPawn(BLACK,1,1);
	this->pieces[1][0]=new dxPawn(BLACK,1,0);

	this->pieces[7][7]=new dxRook(WHITE,7,7);//Rook
	this->pieces[7][6]=new dxKnight(WHITE,7,6);//Knight
	this->pieces[7][5]=new dxBishop(WHITE,7,5);//Bishop
	this->pieces[7][4]=new dxKing(WHITE,7,4);//King
	this->pieces[7][3]=new dxQueen(WHITE,7,3);//Queen
	this->pieces[7][2]=new dxBishop(WHITE,7,2);//Bishop
	this->pieces[7][1]=new dxKnight(WHITE,7,1);//Knight
	this->pieces[7][0]=new dxRook(WHITE,7,0);//Rook
	//pawns
	this->pieces[6][7]=new dxPawn(WHITE,6,7);
	this->pieces[6][6]=new dxPawn(WHITE,6,6);
	this->pieces[6][5]=new dxPawn(WHITE,6,5);
	this->pieces[6][4]=new dxPawn(WHITE,6,4);
	this->pieces[6][3]=new dxPawn(WHITE,6,3);
	this->pieces[6][2]=new dxPawn(WHITE,6,2);
    this->pieces[6][1]=new dxPawn(WHITE,6,1);
	this->pieces[6][0]=new dxPawn(WHITE,6,0);

	
}


/*
====================
Destructor
DevX Team
====================
*/
dxBoard::~dxBoard()
{
}


int dxBoard::GetBlockColor(int x, int y) {
  int x_Color,y_Color;

  x_Color = x%2;
  y_Color = y%2;
  if (y_Color != 0) {
	  if (x_Color != 0) {
	  return 0;
	  }//end if (inner)
	  else{
	       return 1;
	  }//end else (inner)
  }//end if (outer)
  else {
	  if (x_Color != 0) {
	  return 1;
	  }//end if (inner)
	  else{
	      return 0;
          }//end else (inner)
  }//end else (outer)
}

int srow,scolumn;
int crow,ccolumn;

int dxBoard::GetSelectedRow() {
	return srow;
}
int dxBoard::GetSelectedColumn() {
	return scolumn;
}
int dxBoard::GetCurrentRow() {
	return crow;
}
int dxBoard::GetCurrentColumn() {
	return ccolumn;
}



/*
====================
Draw
Draw the board with pieces on the screen
DevX Team
====================
*/
const void dxBoard::Draw() const
{
	system("cls");

	CONSOLE_SCREEN_BUFFER_INFO coninfo; //variable to hold console info
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); //identifier to system created resource
    GetConsoleScreenBufferInfo(hConsole,&coninfo); //retrieves console info using variable as referance parameter.

	for(int i=0;i<ROWS;i++)
	{
		for(int j=0;j<COLUMNS;j++)
		{
			
			int curX,curY,blockColor;

					curY = coninfo.dwCursorPosition.Y;
			        curX = coninfo.dwCursorPosition.X;

	                int tempX,tempY = 0;
			  
	        switch (i) {
	                case 0: tempY=3;
		            break;
		            case 1: tempY=8;
		            break;
		            case 2: tempY=13;
		            break;
		            case 3: tempY=18;
		            break;
		            case 4: tempY=23;
		            break;
		            case 5: tempY=28;
		            break;
		            case 6: tempY=33;
		            break;
		            case 7: tempY=38;
		            break;
		     }

		     switch (j) {
	                case 0: tempX=5;
		            break;
		            case 1: tempX=15;
		            break;
		            case 2: tempX=25;
		            break;
		            case 3: tempX=35;
		            break;
		            case 4: tempX=45;
		            break;
		            case 5: tempX=55;
		            break;
		            case 6: tempX=65;
		            break;
		            case 7: tempX=75;
		            break;
	         }
            blockColor = GetBlockColor(i,j);
	       	stringstream Spacer, 
				         Top, 
				         Middle, 
				         Bottom;

			if(this->isSelected && i==this->selectedPosition.row && j==this->selectedPosition.column)
			{
				
				//cout<<"selected\t";
				// TODO:Draw selected frame
			
				srow = i;
				scolumn = j;
			 unsigned short int color;
		     color = 10;
			 HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
             SetConsoleTextAttribute(hcon,color);
		     if (blockColor == 0) {
		     Top    << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Middle << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Bottom << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Spacer << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     } else {
		     Top    << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n"; 
		     Middle << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n";  
		     Bottom << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n"; 
		     Spacer << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n"; 
			 }
			  
             coninfo.dwCursorPosition.Y = tempY;
             coninfo.dwCursorPosition.X = tempX;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Top.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Spacer.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Middle.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Spacer.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Bottom.str();

			if(this->pieces[i][j])
			this->pieces[i][j]->Draw(i,j);
			color = 7;
			SetConsoleTextAttribute(hcon,color);
			
			}
			else if(i==this->currentPosition.row && j==this->currentPosition.column)
			{
				
				// TODO: Draw current frame
                crow = i;
				ccolumn = j;
			 unsigned short int color;
		     color = 9;
			 HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
			 SetConsoleTextAttribute(hcon,color);
		     if (blockColor == 0) {
		     Top    << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Middle << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Bottom << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Spacer << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     } else {
		     Top    << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Middle << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Bottom << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Spacer << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
			 //code below results in black output rather than blue as char(255) is the equivalent of a blank space
			 /*Top    << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n"; 
		     Middle << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n";  
		     Bottom << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n"; 
		     Spacer << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n";*/ 
			 }
             coninfo.dwCursorPosition.Y = tempY;
             coninfo.dwCursorPosition.X = tempX;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Top.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Spacer.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Middle.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Spacer.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Bottom.str();

			if(this->pieces[i][j])
			this->pieces[i][j]->Draw(i,j);

			color = 7;
			SetConsoleTextAttribute(hcon,color);
			 
				
			}
			else
			{
				//cout<<"normal\t";
				// TODO: Draw normal frame
			 unsigned short int color;
			 HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
			 color = 7;
			 SetConsoleTextAttribute(hcon,color);
		     if (blockColor == 0) {
		     Top    << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Middle << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Bottom << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     Spacer << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219) << char(219)<< char(219) << char(219)<<"\n";
		     } else {
		     Top    << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n"; 
		     Middle << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n";  
		     Bottom << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n"; 
		     Spacer << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255) << char(255)<< char(255) << char(255)<<"\n"; 
			 }
			  
             coninfo.dwCursorPosition.Y = tempY;
             coninfo.dwCursorPosition.X = tempX;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Top.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Spacer.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Middle.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Spacer.str();

             coninfo.dwCursorPosition.Y += 1;
             SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
             cout<<Bottom.str();
			 
			 if(this->pieces[i][j])
				this->pieces[i][j]->Draw(i,j);

			 color = 7;
			 SetConsoleTextAttribute(hcon,color);
			}
			
		}
		//cout<<"\r\n";
	}
	//cout<<"\r\n\r\n";
	
	unsigned short int color = 6;//BROWN
	 HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
     SetConsoleTextAttribute(hcon,color);
	int t,r;
    for (t=0;t<44;t++) {
		if (t==2 || t==43) {
		coninfo.dwCursorPosition.X = 4;
	    coninfo.dwCursorPosition.Y = t;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		stringstream ss;
		ss<<char(219)<<char(219)<<char(219)<<char(219)<<char(219)<<char(219)<<char(219)<<char(219)<<char(219)<<char(219);
		cout<<ss.str()<<ss.str()<<ss.str()<<ss.str()<<ss.str()<<ss.str()<<ss.str()<<ss.str()<<char(219)<<char(219)<<"\n";
		}
		if ((t>2) && (t<43)) {
		coninfo.dwCursorPosition.X = 4;
	    coninfo.dwCursorPosition.Y = t;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		stringstream ss;
		ss<<char(219);
		cout<<ss.str();
		coninfo.dwCursorPosition.X = 85;
	    coninfo.dwCursorPosition.Y = t;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		cout<<ss.str();
		}
	}
	color = 15;//WHITE
	  t=5;
	  r=9;
    SetConsoleTextAttribute(hcon,color);
	for(int j=0;j<COLUMNS;j++)
	{
	  coninfo.dwCursorPosition.X = 1;
	  coninfo.dwCursorPosition.Y = t;
	  SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
	  stringstream ss;
	  ss<<(8-j);
	  cout<<ss.str();
	  t+=5;

	}
	  coninfo.dwCursorPosition.X = r;
	  coninfo.dwCursorPosition.Y = 45;
	  SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
	  stringstream ss;
	  ss << char(255)<<char(255)<<char(255)<<char(255)<< char(255)<< char(255)<<char(255)<<char(255)<<char(255);
	  cout<<"A"<<ss.str()<<"B"<<ss.str()<<"C"<<ss.str()<<"D"<<ss.str()<<"E"<<ss.str()<<"F"<<ss.str()<<"G"<<ss.str()<<"H"<<"\n\n";
	  color=7;//LIGHT GRAY (DEFAULT)
	  SetConsoleTextAttribute(hcon,color);

	  //displays help.
	    int curX = 80;
		int tempY;
		tempY = coninfo.dwCursorPosition.Y+2;
		coninfo.dwCursorPosition.X = curX;
		coninfo.dwCursorPosition.Y += 2;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		cout<<"VALID KEYBOARD INPUT IS:\r\n";
		coninfo.dwCursorPosition.X = curX;
		coninfo.dwCursorPosition.Y += 1;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		cout<<"UP    / W - Moves selector up.";
		coninfo.dwCursorPosition.X = curX;
		coninfo.dwCursorPosition.Y += 1;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		cout<<"DOWN  / S - Moves selector down.";
		coninfo.dwCursorPosition.X = curX;
		coninfo.dwCursorPosition.Y += 1;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		cout<<"LEFT  / A - Moves selector left.";
		coninfo.dwCursorPosition.X = curX;
		coninfo.dwCursorPosition.Y += 1;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		cout<<"RIGHT / D - Moves selector right.";
		coninfo.dwCursorPosition.X = curX;
		coninfo.dwCursorPosition.Y += 1;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		cout<<"ENTER     - Selects current piece.";
		coninfo.dwCursorPosition.X = curX;
		coninfo.dwCursorPosition.Y += 1;
		SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
		cout<<"BACKSPACE - Clears current selection.";

		coninfo.dwCursorPosition.X = 0;
		coninfo.dwCursorPosition.Y = tempY;
        SetConsoleCursorPosition(hConsole,coninfo.dwCursorPosition);
     
}


/*
====================
Input
Ask for arrow keys
DevX Team
====================
*/
int row=0;
int column=0;
int firstMove=0;

void dxBoard::Input()
{     
	do
	{
		//sets default current position the first time any player is to move in the game
		if( this->currentPlayer == WHITE) 
		{
			if (firstMove==0)
			{
			row = 7;
			column = 7;
			firstMove++;
			}
			cout<<"WHITE to move:\r\n"; 
		} else {
			if (firstMove==0)
			{
			row = 0;
			column = 0;
			firstMove++;
			}
			cout<<"BLACK to move:\r\n";
		}

		if(!this->isSelected)
			cout<<"Please select a piece to move.\r\n";
		else
			cout<<"Select select target position for the selected piece.\r\n\r\n";

		//sets position in case input is invalid
		position_t pos;
                pos.row=row;
	    pos.column=column;
		this->currentPosition = pos;
		int input;
		input = _getch();
		  //Validates input
		  if ( ( input == 77 || input == 68 || input == 100 ) && column<7 )//right
		  {
              column++;
		      pos.column=column;
		  } else if ( ( input == 75 || input == 65 || input == 97 ) && column>0 )//left
		  {
			  column--;
			  pos.column=column;
		  } else if ( ( input == 72 || input == 87 || input == 119 ) && row>0 )//up
		  {
			  row--;
			  pos.row=row;
		  } else if ( ( input == 80 || input == 83 || input == 115 ) && row<7 )//down
		  {
			  row++;
			  pos.row=row;
		  } else if ( int(input) == 13 )//enter
		  {
			  if( !this->isSelected )
				this->Select( pos );
			  else
				  this->Move( pos );
			  
		  } else if ( int(input) == 8 )//backspace
		  {
			  this->isSelected = false;
		  }
		  //sets new position if changes by input validation, otherwise keeps old position
		  pos.row=row;
	      pos.column=column;
		  this->currentPosition = pos;
	} while( !( row>=0 && row<=7 && column>=0 && column<=7 ) );
}


/*
====================
Select
Check if position can be selected and select it if yes
DevX Team
====================
*/
bool dxBoard::Select( const position_t source )
{
	if( !this->isSelected && this->pieces[source.row][source.column] && this->pieces[source.row][source.column]->CurrentPlayer()==this->currentPlayer )
	{
		this->selectedPosition.row=source.row;
		this->selectedPosition.column=source.column;
		this->isSelected=true;
		return true;
	}
	return false;
}


/*
====================
Move
Check if piece can be moved on target position, check and move it if yes. Change turn player if all ok
DevX Team
====================
*/
bool dxBoard::Move( const position_t target )
{
	bool pieceCheck=false;
	if( this->isSelected )
	{
		pieceType_t type=this->pieces[this->selectedPosition.row][this->selectedPosition.column]->GetType();
		switch( type )
		{
			case KING:
				pieceCheck=this->CheckKing( target );
				break;
			case QUEEN:
				pieceCheck=this->CheckQueen( target );
				break;
			case BISHOP:
				pieceCheck=this->CheckBishop( target );
				break;
			case KNIGHT:
				pieceCheck=this->CheckKnight( target );
				break;
			case ROOK:
				pieceCheck=this->CheckRook( target );
				break;
			case PAWN:
				pieceCheck=this->CheckPawn( target );
				break;
		}
		if(pieceCheck)
		{
			this->pieces[target.row][target.column]=this->pieces[this->selectedPosition.row][this->selectedPosition.column];
			this->pieces[this->selectedPosition.row][this->selectedPosition.column]=NULL;
			this->selectedPosition=target;
			if( this->currentPlayer==WHITE )
			{
				this->currentPlayer=BLACK;
				row=0;
				column=0;
			}
			else
			{
				this->currentPlayer=WHITE;
				row=7;
				column=7;
			}
			this->isSelected=false;
		}
	}
	return pieceCheck;
}


/*
====================
End
Return game end status
DevX Team
====================
*/
bool dxBoard::End()
{
	return this->isFinished;
}


/*
====================
Check
Check game status, check mates, stalecheck and promotion
DevX Team
====================
*/
void dxBoard::Check()
{
	bool end=false;

	// TODO: Check for check states (checkmate, stalecheck) and promotion

	this->isFinished=end;
}


/*
====================
CheckKing
Check King Movements
DevX Team
====================
*/
bool dxBoard::CheckKing( const position_t pos )
{
	// TODO
	return true;
}


/*
====================
CheckQueen
Check Queen Movements
DevX Team
====================
*/
bool dxBoard::CheckQueen( const position_t pos )
{
	// TODO
	return true;
}


/*
====================
CheckBishop
Check Bishop Movements
DevX Team
====================
*/
bool dxBoard::CheckBishop( const position_t pos )
{
	// TODO
	return true;
}


/*
====================
CheckKnight
Check Knight Movements
DevX Team
====================
*/
bool dxBoard::CheckKnight( const position_t pos )
{
	// TODO
	return true;
}


/*
====================
CheckRook
Check Rook Movements
DevX Team
====================
*/
bool dxBoard::CheckRook( const position_t pos )
{
	// TODO
	if ((selectedPosition.row == pos.row) && (selectedPosition.column == pos.column))
	{
	return false;
	} 

	if ((selectedPosition.row != pos.row)&&(selectedPosition.column != pos.column)) {
	return false;
	}
/* //error, type checking needs repair//
	if (pieces[selectedPosition.row][selectedPosition.column]->CurrentPlayer() == this->currentPlayer)
	{
    cout<<pieces[selectedPosition.row][selectedPosition.column]->CurrentPlayer();
	return false;
	}
*/
	//for columns
	if (selectedPosition.row == pos.row) {
		for (int y(selectedPosition.column-1); y<(pos.column+1);y--){
			if (pieces[selectedPosition.row][y]->CurrentPlayer() != NULL) {
			return false;
			}
		}
	}
	//for rows
	if (selectedPosition.column == pos.column) {
		for (int x(selectedPosition.row-1); x<(pos.row+1);x--){
			if (pieces[x][selectedPosition.column]->CurrentPlayer() != NULL) {
			return false;
			}
	}
	}
	return true;
}


/*
====================
CheckPawn
Check Pawn Movements
DevX Team
====================
*/
bool dxBoard::CheckPawn( const position_t pos )
{
	// TODO
	return true;
}